package JVM.oom;

import java.util.ArrayList;
import java.util.List;

public class GCOverHeadDemo {

    // java.lang.OutOfMemoryError: GC overhead limit exceeded

    // GC回收时间过长，超过98%时间用来做GC，并且回收不到2%的堆内存

    // -Xms10m -Xmx10m -XX:+PrintGCDetails -XX:MaxDirectMemorySize=5m

    public static void main(String[] args) {
        int i = 0;
        List<String> list = new ArrayList<>();
        while (true){
            try {
                list.add(String.valueOf(++i).intern());
            } catch (Throwable e){
                System.out.println("*********************");
                System.out.println(i);
                e.printStackTrace();
            }
        }
    }
}
